<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">   

    <ui:composition template="/templates/interna.xhtml">

	<ui:define name="breadcrumb">

	    <h:form>

		<p:breadCrumb>
		    <p:menuitem value="#{msg.principal}"/>
		    <p:menuitem value="#{msg.menuCadastros}"/>
		    <p:menuitem value="#{msg.subMenuCadastroDecreto}"/>
		    <p:menuitem value="#{msg.decretoConsultar}"/>
		</p:breadCrumb>

	    </h:form>    

	</ui:define>

	<ui:define name="corpo">

	    <h:form id="fConsultarDecreto">

		<p:fieldset id="fsDadosPrincipais" legend="#{msg.decretoDadosDecreto}" >
		    <h:panelGrid columns="5">
			<h:panelGrid columns="1">
			    <p:outputLabel value="#{msg.decretoNumeroDecreto}" for="itNumeroDecreto" />
			    <p:inputText id="itNumeroDecreto" maxlength="10" value="#{consultarDecreto.parametros.numero}"/>
			</h:panelGrid>
			<h:panelGrid columns="1">
			    <p:outputLabel value="#{msg.decretoEmenta}" for="itEmenta"/>
			    <p:inputText id="itEmenta" value="#{consultarDecreto.parametros.ementa}" maxlength="100" size="90"/>
			</h:panelGrid>
			<h:panelGrid columns="1">
			    <p:outputLabel value="#{msg.decretoTiposDecreto}" for="somTiposDecreto"/>
			    <p:selectOneMenu id="somTiposDecreto" value="#{consultarDecreto.parametros.tipoDecreto}" effectSpeed="1" style="width: 320px">
				<f:selectItems value="#{consultarDecreto.listaTiposDecreto}"/>
			    </p:selectOneMenu>
			</h:panelGrid>
		    </h:panelGrid>
		    <h:panelGrid columns="2">
			<h:panelGrid columns="2">
			    <p:outputLabel value="#{msg.decretoPeriodo}:" for="rbgPeriodo"/>
			    <h:selectOneRadio id="rbgPeriodo" value="#{consultarDecreto.parametros.tipoPeriodo}">
				<f:selectItems value="#{consultarDecreto.listaTiposPeriodo}"/>
			    </h:selectOneRadio>
			</h:panelGrid>
			<h:panelGrid columns="2">
			    <h:panelGrid columns="1">
				<p:outputLabel for="dtInicial" value="#{msg.decretoDataInicial}"/>
				<p:calendar id="dtInicial"
					    value="#{consultarDecreto.parametros.dataInicial}"
					    locale="pt"
					    pattern="#{msg.formatoPadraoData}"
					    navigator="true"
					    mode="popup"
					    showOn="button"
					    size="15">
				    <f:convertDateTime pattern="#{msg.formatoPadraoData}"/>
				</p:calendar>				
			    </h:panelGrid>
			    <h:panelGrid columns="1">
				<p:outputLabel for="dtFinal" value="#{msg.decretoDataFinal}"/>
				<p:calendar id="dtFinal"
					    value="#{consultarDecreto.parametros.dataFinal}"
					    locale="pt"
					    pattern="#{msg.formatoPadraoData}"
					    navigator="true"
					    mode="popup"
					    showOn="button"
					    size="15">
				    <f:convertDateTime pattern="#{msg.formatoPadraoData}"/>
				</p:calendar>								
			    </h:panelGrid>
			</h:panelGrid>
		    </h:panelGrid>
		    <p:spacer width="5" height="20"/>
		    <p:commandButton value="#{msg.pesquisar}"
				     icon="ui-icon-search"
				     ajax="false"
				     action="#{consultarDecreto.pesquisar}"/>
		    <p:spacer width="5"/>
		    <p:commandButton value="#{msg.novo}" 
				     action="#{manterDecreto.setup}"
				     icon="ui-icon-plusthick" 
				     ajax="false"/>
		    <p:spacer width="5"/>
		    <p:commandButton value="#{msg.voltar}" 
				     action="#{consultarDecreto.voltar}" 
				     ajax="false" 
				     icon="ui-icon-arrowreturnthick-1-w"
				     immediate="true"/>	
		</p:fieldset>

		<div class="espacamento"/>

		<p:fieldset legend="#{msg.decretoListaDecretos}" 
			    rendered="#{not empty consultarDecreto.dataModel}" >

		    <p:dataTable id="dtDecretos" 
				 value="#{consultarDecreto.dataModel}"
				 var="dec"
				 rows="#{consultarDecreto.registrosPorPagina}"
				 rowsPerPageTemplate="#{consultarDecreto.linhasPorPagina}"
				 paginator="true"
				 paginatorAlwaysVisible="false"
				 paginatorPosition="bottom"
				 lazy="true"
				 emptyMessage="#{msg.nenhumRegistroEncontrado}">

			<p:column headerText="#{msg.decretoNumeroDecreto}" style="width:10%">
			    #{dec.numero}
			</p:column>

			<p:column headerText="#{msg.decretoEmenta}" style="width:45%">
			    #{dec.ementa}
			</p:column>

			<p:column headerText="#{msg.decretoDataPublicacao}" style="width:10%">
			    <h:outputText value="#{dec.dataPublicacao}">
				<f:convertDateTime pattern="#{msg.formatoPadraoData}"/>
			    </h:outputText>
			</p:column>			

			<p:column headerText="#{msg.decretoDataVencimento}" style="width:10%">
			    <h:outputText value="#{dec.dataCaducacao}">
				<f:convertDateTime pattern="#{msg.formatoPadraoData}"/>
			    </h:outputText>
			</p:column>						

			<p:column headerText="#{msg.decretoSituacao}" style="width:10%">
			    #{dec.status}
			</p:column>						

			<p:column headerText="#{msg.acoes}" style="width:15%; text-align: center">
			    <p:commandButton id="btImovelDecreto" icon="ui-icon-home" action="#{imovelDecreto.initImoveisDoDecreto}" oncomplete="pnDecretoImovel.show();" update=":fDecretoImovel:opDecretoImovel">
				<f:setPropertyActionListener value="#{dec.id}" target="#{imovelDecreto.idDecretoSelecionado}"/>
			    </p:commandButton>
			    <p:commandButton id="btDetalharDecreto" icon="ui-icon-search" action="#{manterDecreto.detalhar}">
				<f:setPropertyActionListener value="#{dec.id}" target="#{manterDecreto.idDecretoSelecionado}"/>
			    </p:commandButton>
			    <p:commandButton id="btExcluirDecreto" icon="ui-icon-closethick" onclick="pnConfirmacao.show()">
				<f:setPropertyActionListener value="#{dec}" target="#{consultarDecreto.decretoSelecionado}"/>
			    </p:commandButton>
			    <p:tooltip for="btImovelDecreto" value="#{msg.decretoImovelAssociados}" showEffect="fade" hideEffect="fade" />  
			    <p:tooltip for="btDetalharDecreto" value="#{msg.visualizar}" showEffect="fade" hideEffect="fade" />  
			    <p:tooltip for="btExcluirDecreto" value="#{msg.excluir}" showEffect="fade" hideEffect="fade" />  
			</p:column>

		    </p:dataTable>

		</p:fieldset>


	    </h:form>

	    <ui:include src="/restrito/painel_confirmacao.xhtml">
		<ui:param name="id" value="pnConfirmacao"/>
		<ui:param name="mensagem" value="#{msg.deseja_excluir}"/>
		<ui:param name="bean" value="#{consultarDecreto}"/>
		<ui:param name="action" value="excluir"/>
	    </ui:include>

	    <ui:include src="/restrito/decreto/dialog_associar_imovel_decreto.xhtml"/>
	    <ui:include src="/restrito/decreto/dialog_consultar_imovel.xhtml"/>

	</ui:define>

    </ui:composition>

</html>
